<template>
  <div class="container">
    <section class="f-ptp10">
      <div class='u-title'> 筛选查询</div>
      <div class='u-content u-filter f-ptp10'>
        <div class='u-filter-item'>
          <label for="">输入搜索：</label>
          <el-input class='f-w120' v-model="phone" placeholder="用户名/姓名"></el-input>
        </div>
        <div class='u-filter-item'>
          <label for="">所属部门：</label>
          <el-select class='f-w120' v-model="vip" clearable placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </div>
        <el-button class='f-h40 f-mrt20 f-mbt10' @click="search" type="primary">查询</el-button>
      </div>      
    </section>

    <div class='f-mtp20'>
      <div class='u-title'>
        <h2>组织架构</h2>
        <router-link class='u-title-btn' to='/home/addStaff'>添 加</router-link>
      </div>
      <el-table
        :data="tableData"
        border
        style="width: 100%">
        <el-table-column prop="phone" label="成员账号" width="180"></el-table-column>
        <el-table-column prop="name" label="姓名" width="180"></el-table-column>
        <el-table-column prop="departmentName" label="所属部门" width="180"></el-table-column>
        <el-table-column prop="createTime" label="添加时间" width="180"></el-table-column>
        <el-table-column prop="isUse" label="是否启用" width="180">
          <template slot-scope="scope">
            <el-switch
              @click="handleEdit(scope.$index, scope.row)"
              style="display: block"
              v-model="scope.row.isUse"
              active-color="#1ABC9C"
              inactive-color="#e4e4e4">
            </el-switch>
          </template>
        </el-table-column>
        <el-table-column prop="manage" label="管理">
          <template slot-scope="scope">
            <span @click="handleEdit(scope.$index, scope.row)" class='s-c-green f-csp f-mrt10'>编 辑</span>
            <span class='s-c-red f-csp'>删 除</span>
          </template>
        </el-table-column>
      </el-table>
      <div>
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage1"
          :page-size="100"
          layout="total, prev, pager, next"
          :total="1000">
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  name: 'OrganizationalStructureManage',
  data() {
    return {
      value4: true,
      phone: '',
      password: '',
      tableData: []
    }
  },
  created: function() {
    this.getList();
  },
  methods: {
    getList() {
      const _this = this;
      axios.get(`${this.GLOBAL.baseUrl}/api/admin/getStaffList`).then(res => {
        console.log('res:::', res);

        if(res.data.returnCode == 200) {
          const list = res.data.data;
          for(let i = 0; i < list.length; i++) {
            list[i].isUse = list[i].enable == 1 ? true : false;
          }
          console.log('list:::', list);
          _this.tableData = list;
        }
      }).catch(err => {
        console.error('err::', err);
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
